package com.java2104.mapper;

import com.java2104.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {

    //修改密码的功能
    @Update("update user_inf set password=#{password} where id=#{id}")
    int updatePassword(User user);

    //使用登录名查找用户的方法，在登录验证时使用
    @Select("select * from user_inf where loginname=#{param1} and delete_status=0")
    User findByLoginname(String loginname);

    @Insert("insert into user_inf value(null,#{loginname},#{password},#{role},now(),#{username},'','',0)")
    public int insert(User user);
    @Select("select count(*) from user_inf where loginname=#{param1}")
    public int exist(String loginname);

    public List<User> findList(String loginname,Integer role);
    int updateDeleteStatus(List<Integer> ids);
    @Select("select * from user_inf where id = #{param1}")
    User findByPrimaryKey(Integer id);

    //更新用户信息的方法
    @Update("update user_inf set loginname=#{loginname},username=#{username},role=#{role} where id=#{id}")
    int updateByPrimaryKey(User user);
}
